

<script>
	export default {
		name: "analysisCode",
		data() {
			return {
				
			}
		},
		onLoad(data) {
			
			if (typeof WeixinJSBridge == "object" && typeof WeixinJSBridge.invoke == "function") {
		　　		WeixinJSBridge.invoke('setFontSizeCallback', {
			　　		'fontSize': 0
			　　});
			　　// 重写设置网页字体大小的事件
			　　WeixinJSBridge.on('menu:setfont', function () {
			　　　　WeixinJSBridge.invoke('setFontSizeCallback', {
			　　　　　　'fontSize': 0
			　　　　});
			　　});
			　
			};
			//先判断是不是已经登录过了
			let token = null; // 获取token
			let code = data.code;
			this.login(code);
		},
		methods: {
			async login(code) {
				//用code换取openId
				let obj = await this.$req.singleSinOn('customer/loginweixin', {code})
				console.log(obj)
				
						uni.setStorage({
									key: 'custoken',
									data: obj.data.weiXinLoginToken,
									success: function() {
										
									}
								});
							uni.setStorage({
										key: 'sessionId',
										data: obj.data.sessionId,
										success: function() {
											
										}
									});
							uni.switchTab({
								url: '../tabbar/cardList/index'
							})
				/* if(obj._result&&obj.data){
					//查看当前用户是否已注册
					let status = obj.data.bindMobileNumber?'login':'register';
					let tel = obj.data.bindMobileNumber?obj.data.loginName:'';
					let avater = obj.data.headerUrl?obj.data.headerUrl:'';
					if(obj.data.bindMobileNumber){
						uni.navigateTo({
							url:'../login/login?status='+status+'&tel='+tel+'&avater='+avater
						})
					}
					else{
						uni.showModal({
							title: '提示',
							content: '',
							cancelText: "取消", // 取消按钮的文字  
							confirmText: "立即绑定", // 确认按钮文字  
							showCancel: true, // 是否显示取消按钮，默认为 true
							confirmColor: '#08BA06',
							cancelColor: '#999',
							success: (res) => {
								if(res.confirm) {  
									uni.navigateTo({
										url:'../login/login?status='+status+'&tel='+tel+'&avater='+avater
									})
								} else {  
									uni.setStorage({
										key: 'custoken',
										data: obj.data.weiXinLoginToken,
										success: function(res) {
										
										}
									});
									uni.setStorage({
										key: 'sessionId',
										data: obj.data.sessionId,
										success: function(res) {
										
										}
									});
									uni.switchTab({
										url: '../tabbar/cardList/index'
									})
								}  
							} 
						})
					}
				}
			 */}
		}

	}
</script>

<style scoped>

</style>
